define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'xilujob/user_statistics/index' + location.search,
                    add_url: '',
                    edit_url: '',
                    del_url: '',
                    multi_url: '',
                    detailed_url: 'xilujob/user_statistics/detailed',
                    table: 'xilujob_company_profile',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                search: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'year', title: '年份',visible:false},
                        //{field: 'year', title: '年份',searchList: Config.years,formatter:Table.api.formatter.normal},
                        {field: 'date', title: '日期',operate: false},
                        {field: 'company_count', title: '新增企业', operate:false},
                        {field: 'job_count', title: __('新增职位'), operate:false},
                        {field: 'download_count', title: __('简历下载'), operate:false},
                        {field: 'refresh_count', title: __('刷新次数'), operate:false},
                        {field: 'member_count', title: __('新增求职者'), operate:false},
                        {field: 'apply_count', title: __('新增投递'), operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, buttons:
                                [
                                    {
                                        name: 'detailed',
                                        title: '明细',
                                        text: '明细',
                                        extend: 'data-toggle="tooltip" data-area=\'["100%","100%"]\'',
                                        classname: 'btn btn-xs btn-primary btn-dialog',
                                        url: function(row){
                                            return  $.fn.bootstrapTable.defaults.extend.detailed_url+'?date='+row.date
                                        },
                                    }
                         ]}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        detailed: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'xilujob/user_statistics/detailed' + location.search,
                    add_url: '',
                    edit_url: '',
                    del_url: '',
                    multi_url: '',
                    table: 'xilujob_company_profile',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                search: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'date', title: '日期',operate: false},
                        {field: 'company_count', title: '新增企业', operate:false},
                        {field: 'job_count', title: __('新增职位'), operate:false},
                        {field: 'download_count', title: __('简历下载'), operate:false},
                        {field: 'refresh_count', title: __('刷新次数'), operate:false},
                        {field: 'member_count', title: __('新增求职者'), operate:false},
                        {field: 'apply_count', title: __('新增投递'), operate:false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});